﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using Rhino.Mocks;

namespace Ewk.Math.Algebra.UnitTests.MatrixTests.DoubleTests
{
    [TestClass]
    public class DeterminantTests : DoubleTestBase
    {
        [TestMethod]
        public void Determinant_uses_an_IDeterminantComputer_Only_once_to_compute_the_determinant_of_the_matrix_and_returns_the_value_that_is_returned_by_the_IDeterminantComputer()
        {
            var matrix1 = Identity;

            const double mockedDeterminantValue = 8; // Yes, this is an incorrect value

            DeterminantComputer
                .Expect(
                    computer =>
                    computer.ComputeDeterminant(matrix1))
                .Return(mockedDeterminantValue)
                .Repeat.Once();
            DeterminantComputer.Replay();

            var determinant1 = matrix1.Determinant;
            var determinant2 = matrix1.Determinant;

            Assert.AreEqual(mockedDeterminantValue, determinant1.Value);
            Assert.AreEqual(mockedDeterminantValue, determinant2.Value);

            DeterminantComputer.VerifyAllExpectations();
        }
    }
}